<script setup lang="ts">
import { reactive } from 'vue';
import { useUserStore } from '@/store/user'
import { jumpPage } from '@/hooks/index'
import { goodsList } from '@/config/goods'
const userStore = useUserStore()
const tableData = reactive(goodsList)
</script>
<template>
  <div class="title">首页<span v-if="userStore.user.token">({{ userStore.user.name }})</span></div>
  <div class="goodsList">
    <el-button type="primary" @click="jumpPage('/about')">关于我</el-button>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="ID" width="180" />
      <el-table-column prop="name" label="商品名称" width="180" />
      <el-table-column prop="imgUrl" label="商品图片" align="center">
        <template #default="{ row }">
          <el-image :src="row.imgUrl" fit="cover"></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="price" label="商品价格" />
      <el-table-column prop="description" label="商品简介" />
      <el-table-column label="操作" width="100">
        <el-button size="small" @click="jumpPage('/goodsDetail')">详情</el-button>
      </el-table-column>
    </el-table>
  </div>
</template>
<style lang="scss" scope>
  .title {
    width: 100%;
    text-align: center;
    margin: 40px auto;
    font-size: 30px;
    span {
      font-size: 14px;
      color: #666;
    }
  }
  .goodsList {
    width: 1200px;
    margin: 20px auto;
  }
</style>